package com.deryun.tyl.controller;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import com.deryun.tyl.bean.Purchasing;
import com.deryun.tyl.bean.Purchasing;
import com.deryun.tyl.service.impl.PurchasingServiceImpl;

@Controller
@RequestMapping("purchasing")
public class PurchasingController {

	@Resource(name="purchasingServiceImpl")
	private PurchasingServiceImpl purchasingServiceImpl;
	
	@RequestMapping("/addPurchasing")
	public String addPurchasing(HttpServletRequest request,Purchasing purchasing){
		int result = purchasingServiceImpl.addPurchasing(request,purchasing);
		return "redirect:/ftoac/toLoadCgzx";
	}
	
	/***
	 * 获取所有政策法规
	 * @return
	 */
	@RequestMapping("/getAllPurchasing")
	public List<Purchasing> getAllPurchasing(){
		return purchasingServiceImpl.getAllPurchasing();
	}
	
	/***
	 * 删除制定政策法规
	 * @param id
	 * @return
	 */
	@RequestMapping("/deletePurchasing")
	public String deletePurchasing(int id){
		purchasingServiceImpl.deletePurchasing(id);
		return "redirect:/ftoac/toLoadCgzx";
	}
	
	@RequestMapping("/modifyPurchasing")
	public String modifyPurchasing(Purchasing purchasing){
		purchasingServiceImpl.modifyPurchasing(purchasing);
		return "redirect:/ftoac/toLoadXxgk";
	}
	
	@RequestMapping("/getPurchasingById")
	public String getPurchasingById(HttpServletRequest request,int id){
		Purchasing message = purchasingServiceImpl.getPurchasingById(id);
		request.setAttribute("message", message);
		return "success";
	}
	
	@RequestMapping("/setResult")
	public String setResult(Purchasing purchasing){
		purchasingServiceImpl.setResult(purchasing);
		return "redirect:/ftoac/toLoadXxgk";
	}
}
